import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from "unplugin-auto-import/vite"
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from "unplugin-vue-components/resolvers";
import { resolve} from "path";
export default defineConfig({
  base: process.env.NODE_ENV === 'production' ? '/zxb/h5/' : './',
  plugins: [
      vue(),
      AutoImport({
        imports: [
          // 需要自动导入的插件，自定义导入的API
          'vue',
          'vue-router',
          'pinia'
        ]
      }),
      Components({
        dts: "src/components.d.ts",
        resolvers: [VantResolver()],
      }),
  ],
  resolve: {
    alias: {
      '@': resolve(__dirname, './src'),
      '@components': resolve(__dirname, './src/components'),
    },
    extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
  },
  css: {
    preprocessorOptions: {
      scss: {
        // 引入 mixin.scss 这样就可以在全局中使用 mixin.scss中预定义的变量了
        // 给导入的路径最后加上 ;
        // additionalData: '@import "@/assets/style/mixin.scss";'
      }
    }
  },
  build: {
    target: "ios11",
    outDir: 'dist',
    minify:true,
    sourcemap: false,
    chunkSizeWarningLimit: 1500,
  }
})
